<template>
	<view class="bar">
		<view class="bar_textarea" v-if="user.info.name">
			<textarea :maxlength="-1" v-model="content" class="bar_textarea_style" auto-height placeholder="请输入或复制查询身份证号..."></textarea>
			<view class="bar_textarea_close" v-if="content.length" @click="close">
				<rui-icons icon="close" color="#888"></rui-icons>
			</view>
		</view>
		<view class="bar_nologin" v-else @click="toLogin">
			您还未登录，是否去登录？
		</view>
		<view class="bar_send" @click="change" v-if="user.info.name">
			<rui-icons icon="send" color="#fff" size="45"></rui-icons>
		</view>


	</view>
</template>

<script setup>
	import {
		ref
	} from "vue"
	import {
		userStore
	} from "@/store/index.js"

	let user = userStore();
	
	const emits = defineEmits(['change', 'side'])
	const toLogin = () => {
		emits('side')
	}

	let content = ref("")
	const close = () => {
		content.value = ""
	}
	const change = () => {
		if (!content.value) {
			uni.showToast({
				title: "内容不能为空",
				icon: "none"
			})
			return;
		}
		emits('change', content.value)
		close()
	}
</script>

<style lang="scss" scoped>
	.bar {
		background: #f4faff;
		padding: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: end;
		position: fixed;
		width: calc(100% - 40rpx);
		bottom: 0;
		left: 0;
		z-index: 99;

		&_nologin {
			width: 100%;
			padding: 30rpx 45rpx;
			background: #ddd;
			border-radius: 80rpx;
			box-shadow: 0 3rpx 25rpx rgba(0, 0, 0, .05);
			color: #888;
		}

		&_textarea {
			width: calc(100% - 210rpx);
			background: #fff;
			padding: 30rpx 45rpx;
			border-radius: 80rpx;
			box-shadow: 0 3rpx 25rpx rgba(0, 0, 0, .05);
			display: flex;
			justify-content: space-between;
			align-items: center;

			&_close {
				margin-left: 10rpx;
				height: 40rpx;
			}

			&_style {
				height: auto;
				width: 100%;
				max-height: 130rpx;
				overflow-y: auto;

				&::-webkit-scrollbar {
					width: 0;
				}

				&::-webkit-scrollbar {
					height: 0;
				}
			}
		}

		&_send {
			background: #0279ff;
			padding: 20rpx;
			height: 60rpx;
			width: 60rpx;
			line-height: 60rpx;
			text-align: center;
			border-radius: 50%;
		}
	}
</style>